<?php
$this->breadcrumbs=array(
	'Mtsys Counties'=>array('admin'),
	'管理',
);


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$(this).toggleClass('collapse');
	$('fieldset').toggleClass('collapsed');
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('dict-battery-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<div id="page-header">
	<h1>管理<?php echo $this->moduleName; ?></h1>
    <div id="page-options">
    
	<?php 
	$this->renderPartial('_menu',array(
    'model'=>$model,
    )); 
	?>
    </div>
</div>

<div id="page-unit">
<ul>
<?php 
var_dump($provinces);
if($provinces != NULL){
foreach($provinces as  $sheng){ ?>
	<li>
	<span class="collapse" id="PROVINCE_<?php echo $sheng->PROVINCE_ID;?>"><?php echo $sheng->PROVINCE_NAME;?></span>
    <a href="javascript:void(0);" class="unit_admin add" data-op="add" data-type="CITY" data-id="<?php echo $sheng->PROVINCE_ID;?>">添加</a>
    <a href="javascript:void(0);" class="unit_admin edit"  data-op="edit" data-type="PROVINCE" data-id="<?php echo $sheng->PROVINCE_ID;?>">修改</a>
    <a href="javascript:void(0);" class="unit_admin delete"  data-op="delete" data-type="PROVINCE" data-id="<?php echo $sheng->PROVINCE_ID;?>">删除</a>
    <ul data-super-id="PROVINCE_<?php echo $sheng->PROVINCE_ID;?>">
        <?php 
		foreach($citys as $city){ 
			if($city->PROVINCE_ID == $sheng->PROVINCE_ID){
		?>
        <li>
		<span class="collapse" id="CITY_<?php echo $city->CITY_ID;?>"><?php echo $city->CITY_NAME;?></span>
        <a href="javascript:void(0);" class="unit_admin add" data-op="add" data-type="COUNTY" data-id="<?php echo $city->CITY_ID;?>">添加</a>
        <a href="javascript:void(0);" class="unit_admin edit" data-op="edit" data-type="CITY" data-id="<?php echo $city->CITY_ID;?>">修改</a>
        <a href="javascript:void(0);" class="unit_admin delete" data-op="delete" data-type="CITY" data-id="<?php echo $city->CITY_ID;?>">删除</a> 
        <ul data-super-id="CITY_<?php echo $city->CITY_ID;?>">
            <?php 
			 foreach($countys as $county){ 
				if($county->city->CITY_ID == $city->CITY_ID){
			?>
			<li>
			<span id="COUNTY_<?php echo $county->COUNTY_ID;?>"><?php echo $county->COUNTY_NAME;?></span>
            <a href="javascript:void(0);" class="unit_admin edit" data-op="edit" data-type="COUNTY" data-id="<?php echo $county->COUNTY_ID;?>">修改</a>
            <a href="javascript:void(0);" class="unit_admin delete" data-op="delete" data-type="COUNTY" data-id="<?php echo $county->COUNTY_ID;?>">删除</a></li>
			<?php }}  ?>
        </ul>       
        </li>
        <?php }} ?>
    </ul>
    </li>
<?php }}?>
</ul>
</div>

<?php 
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>'unit',
    'options'=>array(
        'title'=>'新增单位',
        'autoOpen'=>false,
    ),
));
?>
<div class="form unit">
	<div class="grey inline">
	<label>
        <label>单位级别:</label>
        <select name="unit_type">
            <option value="PROVINCE">省级</option>
            <option value="CITY">市级</option>
            <option value="COUNTY">区县</option>
        </select>
    </label>
    <label>
        <label>上级单位:</label>
        <input type="text" name="unit_super_name" value="" />
        <input type="hidden" name="unit_super_id" value="" />
    </label>
    <label>
        <label>单位名称:</label>
        <input type="text" name="unit_name" value="" />    
    </label>
    <input type="button" name="commit" value="提交" class="button blue"/>
    <input type="hidden" name="oper" value="" />
    </div>
</div>
<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');
Yii::app()->clientScript->registerScriptFile('js/pager.unit.js', CClientScript::POS_END);
?>